import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:xinxuan/utils/color_util.dart';

class BarUtil extends StatelessWidget {

  final String title;
  final Color? bgColor;
  final double? height;
  final double borderRadius;
  final double? padding;
  final double? fontSize;
  final bool showLeftBar;

  BarUtil({ required this.title, this.bgColor, this.height, this.borderRadius = 0, this.padding, this.fontSize, this.showLeftBar = true });

  @override
  Widget build(BuildContext context) {
    return Container(
      // height: height ?? 44.h,
      alignment: Alignment.center,
      padding: EdgeInsets.symmetric(horizontal: padding ?? 16.w, vertical: 12.h),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(borderRadius),
        color: bgColor ?? Colors.transparent
      ),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          showLeftBar ? Container(
            height: 16.h,
            width: 3.w,
            margin: EdgeInsets.only(right: 6.w),
            decoration: BoxDecoration(
              color: bgMainColor,
              borderRadius: BorderRadius.circular(5.w)
            ),
          ) : Container(),
          Text(
            title,
            style: TextStyle(
              color: textBlackColor,
              fontWeight: FontWeight.bold,
              fontSize: fontSize ?? 14.sp,
            ),
          )
        ],
      ),
    );
  }
}